<?php

use think\migration\Migrator;
use think\migration\db\Column;

class MatchTable extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $this->table('match', ['comment'=>'赛事'])
            ->addColumn(Column::string('name', 200)->setComment("比赛名称"))
            ->addColumn(Column::text('desc')->setComment("赛事描述")->setNullable())
            ->addColumn(Column::integer('start_time')->setComment("开始时间"))
            ->addColumn(Column::integer('end_time')->setComment("结束时间"))
            ->addColumn(Column::string('cate_id')->setComment("分类id"))
            ->addColumn(Column::tinyInteger('is_fees')->setComment("收费类型:0免费,1收费")->setDefault(0))
            ->addColumn(Column::decimal('cost', 10, 2)->setDefault(0)->setComment("收费金额")->setNullable())
            ->addColumn(Column::string('images')->setComment("图片")->setNullable())
            ->addColumn(Column::tinyInteger('status')->setComment('比赛状态：0未开始1进行中2已结束')->setDefault(0))
            ->addColumn(Column::tinyInteger('sort')->setComment('比赛状态：0未开始1进行中2已结束')->setDefault(0)->setNullable())
            ->addColumn(Column::string('auth')->setNullable()->setComment('作者'))
            ->addColumn(Column::integer('user_id')->setNullable()->setComment('创建人'))
            ->addColumn(Column::longText('agreement')->setNullable()->setComment('协议'))
            ->addColumn(Column::integer('create_time')->setComment('创建时间')->setNullable())
            ->addColumn(Column::integer('update_time')->setComment('修改时间')->setNullable())
            ->addColumn(Column::integer('delete_time')->setComment('删除时间')->setNullable())
            ->create();
    }
}
